package org.jeecgframework.core.extend.video;

import org.jeecgframework.core.util.FileUtils;

public class VideoConverter {
	AVIConverter avic = null;
	FLVConverter flvc = null;
	
	public VideoConverter (String webroot){	
		avic = new MenCoderConverter(webroot+"video/mencoder/mencoder.exe");
		flvc = new FFMpegConverter(webroot+"video/ffmpeg/bin/ffmpeg.exe");
	}
	
	public void converttoflv(String inputfile , String outputfile){
		if(inputfile.endsWith(".avi") || inputfile.endsWith(".AVI")){
			flvc.convert2Flv(inputfile, outputfile);
		}else{
			String temp = FileUtils.getFilePrefix(outputfile)+".avi";
			avic.convert2Avi(inputfile, temp);
			flvc.convert2Flv(temp, outputfile);
		}	
	}
}
